/**
 * 用户登录状态模块
 */
export default {
    state: {
        user: "", // 登录的用户对象
        userToken:"",//token
        userAddress:"",//用户地址列表
        userOrderList:"",//用户订单
        showLogin: false // 用于控制是否显示登录组件
    },
    getters: {
        getUser(state) {
            return state.user
        },
        getUserToken(state){
            return state.userToken
        },
        getUserAddress(state){
            return state.userAddress
        },
        getUserOrderList(state){
            return state.userOrderList
        },
        getShowLogin(state) {
            return state.showLogin
        }
    },
    mutations: {
        setUser(state, data) {
            state.user = data;
        },
        setUserToken(state, data){
            state.userToken = data;
        },
        setUserAddress(state, data){
            state.userAddress = data;
        },
        setUserOrderList(state, data){
            state.userOrderList = data;
        },
        setShowLogin(state, data) {
            state.showLogin = data;
        }
    },
    actions: {
        setUser({commit}, data) {
            commit('setUser', data);
        },
        setUserToken({commit},data){
            commit('setUserToken', data);
        },
        setUserAddress({commit},data){
            commit('setUserAddress', data);
        },
        setUserOrderList({commit},data){
            commit('setUserOrderList', data);
        },
        setShowLogin({commit}, data) {
            commit('setShowLogin', data);
        }
    }
}